package com.example.test.retrofit

import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit

class RetrofitHelper {

    ///api/v1/auth/login
    //132.232.0.73:8099
    //pwd
    //type 0-1-2
    //userName


    companion object{

        //    val baseUrl = "https://api.github.com/"
        val baseUrl = "http://132.232.0.73:8099/"


        fun getApi(): ApiService {
            val client = OkHttpClient.Builder()
                .connectTimeout(10, TimeUnit.SECONDS)       //连接超时
                .readTimeout(10, TimeUnit.SECONDS)          //读取超时
                .writeTimeout(10, TimeUnit.SECONDS)         //写超时
                .build()
            val retrofit = Retrofit.Builder().client(client).baseUrl(baseUrl)
                .addConverterFactory(GsonConverterFactory.create()).build()

            return retrofit.create(ApiService::class.java)
        }
    }
}